package com.sunwayhorizo.health.platform.security.persistent;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.TableGenerator;

import com.sunwayhorizo.health.platform.util.BeanHelper;

@Entity
@TableGenerator(name = "SecurityDataObjectAccount_IdGenerator", table = "ET_Id_Generator", pkColumnName = "pkColumn", valueColumnName = "valueColumn", pkColumnValue = "SECURITY_DATA_OBJECT_ACCOUNT_ID",allocationSize=1)
@Table(name = "SECURITY_DATA_OBJECT_ACCOUNT", schema = "ETS")
public class SecurityDataObjectAccount implements java.io.Serializable {

	@Id
	@GeneratedValue(strategy = GenerationType.TABLE, generator = "SecurityDataObjectAccount_IdGenerator")
	@Column(name = "DATA_OBJECT_ACCOUNT_ID", unique = true, nullable = false, length = 32)
	private String dataObjectAccountId;
	
	@ManyToOne(cascade = {CascadeType.PERSIST,CascadeType.MERGE})
	@JoinColumn(name = "DATA_OBJECT_ID")
	private SecurityDataObject dataObject;
	
	@ManyToOne(cascade = {CascadeType.PERSIST,CascadeType.MERGE})
	@JoinColumn(name = "ACCOUNT_ID")
	private SecurityAccount account;

	public SecurityDataObjectAccount() {
	}

	public SecurityDataObjectAccount(String dataObjectAccountId) {
		this.dataObjectAccountId = dataObjectAccountId;
	}

	public SecurityDataObjectAccount(String dataObjectAccountId,
			SecurityDataObject dataObject,
			SecurityAccount account) {
		this.dataObjectAccountId = dataObjectAccountId;
		this.dataObject = dataObject;
		this.account = account;
	}

	public String getDataObjectAccountId() {
		return this.dataObjectAccountId;
	}

	public void setDataObjectAccountId(String dataObjectAccountId) {
		this.dataObjectAccountId = dataObjectAccountId;
	}

	public SecurityDataObject getDataObject() {
		return this.dataObject;
	}

	public void setDataObject(SecurityDataObject dataObject) {
		this.dataObject = dataObject;
	}

	public SecurityAccount getAccount() {
		return this.account;
	}

	public void setAccount(SecurityAccount account) {
		this.account = account;
	}
	
	@Override
	public String toString() {
		return BeanHelper.toString(this);
	}
}
